/*
 * Decompiled with CFR 0.150.
 * 
 * Could not load the following classes:
 *  cn.hutool.core.util.ObjectUtil
 *  com.alibaba.fastjson.JSON
 *  de.felixroske.jfxsupport.FXMLController
 *  javafx.beans.value.ChangeListener
 *  javafx.beans.value.ObservableValue
 *  javafx.collections.FXCollections
 *  javafx.collections.ObservableList
 *  javafx.event.EventHandler
 *  javafx.fxml.FXML
 *  javafx.fxml.Initializable
 *  javafx.scene.Node
 *  javafx.scene.control.Alert
 *  javafx.scene.control.Alert$AlertType
 *  javafx.scene.control.Button
 *  javafx.scene.control.CheckBox
 *  javafx.scene.control.ScrollPane
 *  javafx.scene.control.TableCell
 *  javafx.scene.control.TableColumn
 *  javafx.scene.control.TableView
 *  javafx.scene.control.TextField
 *  javafx.scene.control.cell.PropertyValueFactory
 *  javafx.scene.input.KeyCode
 *  javafx.scene.input.KeyEvent
 *  javafx.scene.layout.VBox
 *  javafx.stage.Modality
 *  javafx.util.Callback
 *  org.springframework.beans.factory.annotation.Autowired
 *  org.springframework.util.CollectionUtils
 *  org.springframework.util.StringUtils
 */
package com.gys.controller.payingBank;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.gys.GysApplication;
import com.gys.common.business.BankInfoUtil;
import com.gys.common.data.HttpJson;
import com.gys.controller.BaseController;
import com.gys.controller.index.IndexController;
import com.gys.controller.payingBank.AddBankInfoController;
import com.gys.controller.payingBank.AvailableStoreController;
import com.gys.controller.payingBank.EditBankInfoController;
import com.gys.data.payingBank.BankInfoInData;
import com.gys.data.payingBank.BankInfoOutData;
import com.gys.view.payingBank.addBankInfoView;
import com.gys.view.payingBank.availableStoreView;
import com.gys.view.payingBank.editBankInfoView;
import de.felixroske.jfxsupport.FXMLController;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.ResourceBundle;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.util.Callback;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

@FXMLController
public class PayingBankController
extends BaseController
implements Initializable {
    private ObservableList<BankInfoOutData> observableTableList = FXCollections.observableArrayList(new ArrayList());
    @FXML
    private VBox vBox;
    @FXML
    private TableColumn<BankInfoOutData, String> gsbsBkName;
    @FXML
    private ScrollPane scrollPane;
    @FXML
    private TableColumn<BankInfoOutData, String> gsbsBrsId;
    @FXML
    private TableView<BankInfoOutData> tableView;
    @FXML
    private TableColumn<BankInfoOutData, CheckBox> checkBox;
    @FXML
    private TableColumn<BankInfoOutData, String> index;
    @FXML
    private TableColumn<BankInfoOutData, String> gsbsBkAccount;
    @FXML
    private TextField gsbsBrId;
    @FXML
    private TextField gsbsBankName;
    @FXML
    private Button setUpBtn;
    @FXML
    private Button saveBtn;
    @FXML
    private TextField gsbsBankAccount;
    @Autowired
    private IndexController indexController;
    @Autowired
    private AddBankInfoController addBankInfoController;
    @Autowired
    private EditBankInfoController editBankInfoController;
    @Autowired
    private AvailableStoreController availableStoreController;

    public void initialize(URL location, ResourceBundle resources) {
        this.scrollPane.setPrefWidth(this.getContentWidth());
        this.scrollPane.setPrefHeight(this.getContentHeight());
        this.vBox.setPrefWidth(this.getContentWidth());
        this.vBox.setPrefHeight(this.getContentHeight());
        this.tableView.setPrefWidth(this.getContentWidth());
        this.init();
    }

    @Override
    public void init() {
        if (ObjectUtil.isEmpty(this.scrollPane)) {
            return;
        }
        this.indexController.scrollContentPane.setOnKeyReleased((EventHandler)new EventHandler<KeyEvent>(){

            public void handle(KeyEvent e) {
                if (e.getCode() == KeyCode.ENTER) {
                    PayingBankController.this.queryAction();
                } else if (e.getCode() == KeyCode.F1) {
                    PayingBankController.this.addAction();
                } else if (e.getCode() == KeyCode.F3) {
                    PayingBankController.this.editAction();
                }
                e.consume();
            }
        });
        this.bingTableCell();
        this.initTable();
    }

    public TableView<BankInfoOutData> initTable() {
        BankInfoInData inData = new BankInfoInData();
        if (ObjectUtil.isNotEmpty(this.gsbsBrId.getText())) {
            inData.setGsbsBrId(this.gsbsBrId.getText());
        }
        if (ObjectUtil.isNotEmpty(this.gsbsBankName.getText())) {
            inData.setGsbsBankName(this.gsbsBankName.getText());
        }
        if (ObjectUtil.isNotEmpty(this.gsbsBankAccount.getText())) {
            inData.setGsbsBankAccount(this.gsbsBankAccount.getText());
        }
        List dataList = null;
        HttpJson rsp = BankInfoUtil.getBankInfoList(inData);
        if (!rsp.isSuccess()) {
            Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", rsp.getMsg());
            alert.showAndWait();
            return new TableView();
        }
        dataList = JSON.parseArray((String)rsp.getMsg(), BankInfoOutData.class);
        this.observableTableList.clear();
        this.observableTableList = FXCollections.observableArrayList((Collection)dataList);
        this.bingTableCell();
        this.tableView.setItems(this.observableTableList);
        return this.tableView;
    }

    private void bingTableCell() {
        this.index.setCellValueFactory((Callback)new PropertyValueFactory(this.index.getId()));
        this.checkBox.setCellValueFactory(cellData -> ((BankInfoOutData)cellData.getValue()).getCheckBox().getCustomCheckBox());
        this.checkBox.setCellFactory(col -> {
            TableCell<BankInfoOutData, CheckBox> cell = new TableCell<BankInfoOutData, CheckBox>(){

                protected void updateItem(CheckBox item, boolean empty) {
                    super.updateItem(item, empty);
                    this.setGraphic((Node)item);
                    if (item != null) {
                        item.setOnMouseClicked(col -> {
                            if (CollectionUtils.isEmpty((Collection)PayingBankController.this.observableTableList)) {
                                return;
                            }
                            int index = this.getIndex();
                            for (int i = 0; i < PayingBankController.this.observableTableList.size(); ++i) {
                                if (i == index) continue;
                                ((BankInfoOutData)PayingBankController.this.observableTableList.get(i)).getCheckBox().setSelectStatus(false);
                            }
                            if (((BankInfoOutData)PayingBankController.this.observableTableList.get(index)).getCheckBox().isSelected().booleanValue()) {
                                PayingBankController.this.setUpBtn.setDisable(false);
                            } else {
                                PayingBankController.this.setUpBtn.setDisable(true);
                            }
                        });
                    }
                }
            };
            return cell;
        });
        this.gsbsBrsId.setCellValueFactory((Callback)new PropertyValueFactory("gsbsBrId"));
        this.gsbsBkName.setCellValueFactory((Callback)new PropertyValueFactory("gsbsBankName"));
        this.gsbsBkAccount.setCellValueFactory((Callback)new PropertyValueFactory("gsbsBankAccount"));
        this.tableView.getSelectionModel().selectedItemProperty().addListener((ChangeListener)new ChangeListener<BankInfoOutData>(){

            public void changed(ObservableValue<? extends BankInfoOutData> observable, BankInfoOutData oldValue, BankInfoOutData newValue) {
                if (CollectionUtils.isEmpty((Collection)PayingBankController.this.observableTableList)) {
                    return;
                }
                for (int i = 0; i < PayingBankController.this.observableTableList.size(); ++i) {
                    if (i == newValue.getIndex() - 1) {
                        ((BankInfoOutData)PayingBankController.this.observableTableList.get(i)).getCheckBox().setSelectStatus(true);
                        PayingBankController.this.setUpBtn.setDisable(false);
                        continue;
                    }
                    ((BankInfoOutData)PayingBankController.this.observableTableList.get(i)).getCheckBox().setSelectStatus(false);
                }
            }
        });
    }

    @FXML
    void queryAction() {
        Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", null);
        if (StringUtils.isEmpty(this.gsbsBrId.getText().trim()) && StringUtils.isEmpty(this.gsbsBankName.getText().trim()) && StringUtils.isEmpty(this.gsbsBankAccount.getText().trim())) {
            alert.setContentText("\u5fc5\u987b\u81f3\u5c11\u586b\u5199\u4e00\u9879\u5185\u5bb9\u8fdb\u884c\u67e5\u8be2\uff01");
            alert.showAndWait();
            return;
        }
        this.initTable();
    }

    @FXML
    void addAction() {
        this.addBankInfoController.init();
        GysApplication.showView(addBankInfoView.class, (Modality)Modality.APPLICATION_MODAL);
    }

    @FXML
    void save() {
    }

    @FXML
    void editAction() {
        List<Integer> indexList = this.getSelectIndex();
        if (ObjectUtil.isEmpty(indexList)) {
            Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", "\u8bf7\u9009\u62e9\u8bb0\u5f55");
            alert.showAndWait();
            return;
        }
        this.editBankInfoController.init();
        GysApplication.showView(editBankInfoView.class, (Modality)Modality.APPLICATION_MODAL);
    }

    @FXML
    void setUpAction() {
        this.availableStoreController.init();
        GysApplication.showView(availableStoreView.class, (Modality)Modality.APPLICATION_MODAL);
    }

    public List<Integer> getSelectIndex() {
        ArrayList<Integer> ids = new ArrayList<Integer>();
        if (!CollectionUtils.isEmpty(this.observableTableList)) {
            for (BankInfoOutData i : this.observableTableList) {
                if (!i.getCheckBox().isSelected().booleanValue()) continue;
                ids.add(i.getIndex());
            }
        }
        return ids;
    }

    @FXML
    private void reset() {
        this.gsbsBrId.clear();
        this.gsbsBankName.clear();
        this.gsbsBankAccount.clear();
    }

    public ObservableList<BankInfoOutData> getObservableTableList() {
        return this.observableTableList;
    }

    public VBox getVBox() {
        return this.vBox;
    }

    public TableColumn<BankInfoOutData, String> getGsbsBkName() {
        return this.gsbsBkName;
    }

    public ScrollPane getScrollPane() {
        return this.scrollPane;
    }

    public TableColumn<BankInfoOutData, String> getGsbsBrsId() {
        return this.gsbsBrsId;
    }

    public TableView<BankInfoOutData> getTableView() {
        return this.tableView;
    }

    public TableColumn<BankInfoOutData, CheckBox> getCheckBox() {
        return this.checkBox;
    }

    public TableColumn<BankInfoOutData, String> getIndex() {
        return this.index;
    }

    public TableColumn<BankInfoOutData, String> getGsbsBkAccount() {
        return this.gsbsBkAccount;
    }

    public TextField getGsbsBrId() {
        return this.gsbsBrId;
    }

    public TextField getGsbsBankName() {
        return this.gsbsBankName;
    }

    public Button getSetUpBtn() {
        return this.setUpBtn;
    }

    public Button getSaveBtn() {
        return this.saveBtn;
    }

    public TextField getGsbsBankAccount() {
        return this.gsbsBankAccount;
    }

    public IndexController getIndexController() {
        return this.indexController;
    }

    public AddBankInfoController getAddBankInfoController() {
        return this.addBankInfoController;
    }

    public EditBankInfoController getEditBankInfoController() {
        return this.editBankInfoController;
    }

    public AvailableStoreController getAvailableStoreController() {
        return this.availableStoreController;
    }

    public void setObservableTableList(ObservableList<BankInfoOutData> observableTableList) {
        this.observableTableList = observableTableList;
    }

    public void setVBox(VBox vBox) {
        this.vBox = vBox;
    }

    public void setGsbsBkName(TableColumn<BankInfoOutData, String> gsbsBkName) {
        this.gsbsBkName = gsbsBkName;
    }

    public void setScrollPane(ScrollPane scrollPane) {
        this.scrollPane = scrollPane;
    }

    public void setGsbsBrsId(TableColumn<BankInfoOutData, String> gsbsBrsId) {
        this.gsbsBrsId = gsbsBrsId;
    }

    public void setTableView(TableView<BankInfoOutData> tableView) {
        this.tableView = tableView;
    }

    public void setCheckBox(TableColumn<BankInfoOutData, CheckBox> checkBox) {
        this.checkBox = checkBox;
    }

    public void setIndex(TableColumn<BankInfoOutData, String> index) {
        this.index = index;
    }

    public void setGsbsBkAccount(TableColumn<BankInfoOutData, String> gsbsBkAccount) {
        this.gsbsBkAccount = gsbsBkAccount;
    }

    public void setGsbsBrId(TextField gsbsBrId) {
        this.gsbsBrId = gsbsBrId;
    }

    public void setGsbsBankName(TextField gsbsBankName) {
        this.gsbsBankName = gsbsBankName;
    }

    public void setSetUpBtn(Button setUpBtn) {
        this.setUpBtn = setUpBtn;
    }

    public void setSaveBtn(Button saveBtn) {
        this.saveBtn = saveBtn;
    }

    public void setGsbsBankAccount(TextField gsbsBankAccount) {
        this.gsbsBankAccount = gsbsBankAccount;
    }

    public void setIndexController(IndexController indexController) {
        this.indexController = indexController;
    }

    public void setAddBankInfoController(AddBankInfoController addBankInfoController) {
        this.addBankInfoController = addBankInfoController;
    }

    public void setEditBankInfoController(EditBankInfoController editBankInfoController) {
        this.editBankInfoController = editBankInfoController;
    }

    public void setAvailableStoreController(AvailableStoreController availableStoreController) {
        this.availableStoreController = availableStoreController;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof PayingBankController)) {
            return false;
        }
        PayingBankController other = (PayingBankController)o;
        if (!other.canEqual(this)) {
            return false;
        }
        ObservableList<BankInfoOutData> this$observableTableList = this.getObservableTableList();
        ObservableList<BankInfoOutData> other$observableTableList = other.getObservableTableList();
        if (this$observableTableList == null ? other$observableTableList != null : !this$observableTableList.equals(other$observableTableList)) {
            return false;
        }
        VBox this$vBox = this.getVBox();
        VBox other$vBox = other.getVBox();
        if (this$vBox == null ? other$vBox != null : !this$vBox.equals(other$vBox)) {
            return false;
        }
        TableColumn<BankInfoOutData, String> this$gsbsBkName = this.getGsbsBkName();
        TableColumn<BankInfoOutData, String> other$gsbsBkName = other.getGsbsBkName();
        if (this$gsbsBkName == null ? other$gsbsBkName != null : !this$gsbsBkName.equals(other$gsbsBkName)) {
            return false;
        }
        ScrollPane this$scrollPane = this.getScrollPane();
        ScrollPane other$scrollPane = other.getScrollPane();
        if (this$scrollPane == null ? other$scrollPane != null : !this$scrollPane.equals(other$scrollPane)) {
            return false;
        }
        TableColumn<BankInfoOutData, String> this$gsbsBrsId = this.getGsbsBrsId();
        TableColumn<BankInfoOutData, String> other$gsbsBrsId = other.getGsbsBrsId();
        if (this$gsbsBrsId == null ? other$gsbsBrsId != null : !this$gsbsBrsId.equals(other$gsbsBrsId)) {
            return false;
        }
        TableView<BankInfoOutData> this$tableView = this.getTableView();
        TableView<BankInfoOutData> other$tableView = other.getTableView();
        if (this$tableView == null ? other$tableView != null : !this$tableView.equals(other$tableView)) {
            return false;
        }
        TableColumn<BankInfoOutData, CheckBox> this$checkBox = this.getCheckBox();
        TableColumn<BankInfoOutData, CheckBox> other$checkBox = other.getCheckBox();
        if (this$checkBox == null ? other$checkBox != null : !this$checkBox.equals(other$checkBox)) {
            return false;
        }
        TableColumn<BankInfoOutData, String> this$index = this.getIndex();
        TableColumn<BankInfoOutData, String> other$index = other.getIndex();
        if (this$index == null ? other$index != null : !this$index.equals(other$index)) {
            return false;
        }
        TableColumn<BankInfoOutData, String> this$gsbsBkAccount = this.getGsbsBkAccount();
        TableColumn<BankInfoOutData, String> other$gsbsBkAccount = other.getGsbsBkAccount();
        if (this$gsbsBkAccount == null ? other$gsbsBkAccount != null : !this$gsbsBkAccount.equals(other$gsbsBkAccount)) {
            return false;
        }
        TextField this$gsbsBrId = this.getGsbsBrId();
        TextField other$gsbsBrId = other.getGsbsBrId();
        if (this$gsbsBrId == null ? other$gsbsBrId != null : !this$gsbsBrId.equals(other$gsbsBrId)) {
            return false;
        }
        TextField this$gsbsBankName = this.getGsbsBankName();
        TextField other$gsbsBankName = other.getGsbsBankName();
        if (this$gsbsBankName == null ? other$gsbsBankName != null : !this$gsbsBankName.equals(other$gsbsBankName)) {
            return false;
        }
        Button this$setUpBtn = this.getSetUpBtn();
        Button other$setUpBtn = other.getSetUpBtn();
        if (this$setUpBtn == null ? other$setUpBtn != null : !this$setUpBtn.equals(other$setUpBtn)) {
            return false;
        }
        Button this$saveBtn = this.getSaveBtn();
        Button other$saveBtn = other.getSaveBtn();
        if (this$saveBtn == null ? other$saveBtn != null : !this$saveBtn.equals(other$saveBtn)) {
            return false;
        }
        TextField this$gsbsBankAccount = this.getGsbsBankAccount();
        TextField other$gsbsBankAccount = other.getGsbsBankAccount();
        if (this$gsbsBankAccount == null ? other$gsbsBankAccount != null : !this$gsbsBankAccount.equals(other$gsbsBankAccount)) {
            return false;
        }
        IndexController this$indexController = this.getIndexController();
        IndexController other$indexController = other.getIndexController();
        if (this$indexController == null ? other$indexController != null : !(this$indexController).equals(other$indexController)) {
            return false;
        }
        AddBankInfoController this$addBankInfoController = this.getAddBankInfoController();
        AddBankInfoController other$addBankInfoController = other.getAddBankInfoController();
        if (this$addBankInfoController == null ? other$addBankInfoController != null : !(this$addBankInfoController).equals(other$addBankInfoController)) {
            return false;
        }
        EditBankInfoController this$editBankInfoController = this.getEditBankInfoController();
        EditBankInfoController other$editBankInfoController = other.getEditBankInfoController();
        if (this$editBankInfoController == null ? other$editBankInfoController != null : !(this$editBankInfoController).equals(other$editBankInfoController)) {
            return false;
        }
        AvailableStoreController this$availableStoreController = this.getAvailableStoreController();
        AvailableStoreController other$availableStoreController = other.getAvailableStoreController();
        return !(this$availableStoreController == null ? other$availableStoreController != null : !(this$availableStoreController).equals(other$availableStoreController));
    }

    protected boolean canEqual(Object other) {
        return other instanceof PayingBankController;
    }

    public int hashCode() {
        int PRIME = 59;
        int result = 1;
        ObservableList<BankInfoOutData> $observableTableList = this.getObservableTableList();
        result = result * 59 + ($observableTableList == null ? 43 : $observableTableList.hashCode());
        VBox $vBox = this.getVBox();
        result = result * 59 + ($vBox == null ? 43 : $vBox.hashCode());
        TableColumn<BankInfoOutData, String> $gsbsBkName = this.getGsbsBkName();
        result = result * 59 + ($gsbsBkName == null ? 43 : $gsbsBkName.hashCode());
        ScrollPane $scrollPane = this.getScrollPane();
        result = result * 59 + ($scrollPane == null ? 43 : $scrollPane.hashCode());
        TableColumn<BankInfoOutData, String> $gsbsBrsId = this.getGsbsBrsId();
        result = result * 59 + ($gsbsBrsId == null ? 43 : $gsbsBrsId.hashCode());
        TableView<BankInfoOutData> $tableView = this.getTableView();
        result = result * 59 + ($tableView == null ? 43 : $tableView.hashCode());
        TableColumn<BankInfoOutData, CheckBox> $checkBox = this.getCheckBox();
        result = result * 59 + ($checkBox == null ? 43 : $checkBox.hashCode());
        TableColumn<BankInfoOutData, String> $index = this.getIndex();
        result = result * 59 + ($index == null ? 43 : $index.hashCode());
        TableColumn<BankInfoOutData, String> $gsbsBkAccount = this.getGsbsBkAccount();
        result = result * 59 + ($gsbsBkAccount == null ? 43 : $gsbsBkAccount.hashCode());
        TextField $gsbsBrId = this.getGsbsBrId();
        result = result * 59 + ($gsbsBrId == null ? 43 : $gsbsBrId.hashCode());
        TextField $gsbsBankName = this.getGsbsBankName();
        result = result * 59 + ($gsbsBankName == null ? 43 : $gsbsBankName.hashCode());
        Button $setUpBtn = this.getSetUpBtn();
        result = result * 59 + ($setUpBtn == null ? 43 : $setUpBtn.hashCode());
        Button $saveBtn = this.getSaveBtn();
        result = result * 59 + ($saveBtn == null ? 43 : $saveBtn.hashCode());
        TextField $gsbsBankAccount = this.getGsbsBankAccount();
        result = result * 59 + ($gsbsBankAccount == null ? 43 : $gsbsBankAccount.hashCode());
        IndexController $indexController = this.getIndexController();
        result = result * 59 + ($indexController == null ? 43 : ($indexController).hashCode());
        AddBankInfoController $addBankInfoController = this.getAddBankInfoController();
        result = result * 59 + ($addBankInfoController == null ? 43 : ($addBankInfoController).hashCode());
        EditBankInfoController $editBankInfoController = this.getEditBankInfoController();
        result = result * 59 + ($editBankInfoController == null ? 43 : ($editBankInfoController).hashCode());
        AvailableStoreController $availableStoreController = this.getAvailableStoreController();
        result = result * 59 + ($availableStoreController == null ? 43 : ($availableStoreController).hashCode());
        return result;
    }

    public String toString() {
        return "PayingBankController(observableTableList=" + this.getObservableTableList() + ", vBox=" + this.getVBox() + ", gsbsBkName=" + this.getGsbsBkName() + ", scrollPane=" + this.getScrollPane() + ", gsbsBrsId=" + this.getGsbsBrsId() + ", tableView=" + this.getTableView() + ", checkBox=" + this.getCheckBox() + ", index=" + this.getIndex() + ", gsbsBkAccount=" + this.getGsbsBkAccount() + ", gsbsBrId=" + this.getGsbsBrId() + ", gsbsBankName=" + this.getGsbsBankName() + ", setUpBtn=" + this.getSetUpBtn() + ", saveBtn=" + this.getSaveBtn() + ", gsbsBankAccount=" + this.getGsbsBankAccount() + ", indexController=" + this.getIndexController() + ", addBankInfoController=" + this.getAddBankInfoController() + ", editBankInfoController=" + this.getEditBankInfoController() + ", availableStoreController=" + this.getAvailableStoreController() + ")";
    }
}

